import React from 'react'
import {useSelector,useDispatch} from 'react-redux'
import {increment} from '@/store/modules/counterSlice'
export default function Counter() {
    const state=useSelector((state)=>{
       return state.counterKey
    })
    const dispatch=useDispatch()
  return (
    <div>
        <h1>@ruduxjs/toolkit版的计数器</h1>
        <h2>{state.count}</h2>
        <button onClick={()=>{
            dispatch(increment())
        }}>+</button>
    </div>
  )
}
